﻿using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace Allegro.TaskExecution
{
    /// <summary>
    /// Type of log event
    /// </summary>
    public enum LogEventTypes : int
    {
        /// <summary>
        /// General event
        /// </summary>
        OtherEvent = 0,
        /// <summary>
        /// A task event was logged. Event source is ITask
        /// </summary>
        TaskEvent = 1,
        /// <summary>
        /// A task activity event was logged. Event source is a task activity
        /// </summary>
        ActivityEvent = 2,
        /// <summary>
        /// An application event was logged. Event source is an application object
        /// </summary>
        ApplicationEvent = 3,
    }

    /// <summary>
    /// Event triggered upon logging
    /// </summary>
    /// <param name="eventSource">Object that triggered the event</param>
    /// <param name="eventInfo">Event information</param>
    public delegate void LogEvent(object eventSource, LogEventArgs eventInfo);

    /// <summary>
    /// Log event args
    /// </summary>
    public class LogEventArgs : EventArgs
    {
        private object _eventSource;
        private LogEventTypes _eventType;
        private string _eventMessage;
        private System.Diagnostics.TraceLevel _traceLevel;

        internal LogEventArgs(object eventSource, LogEventTypes eventType, string eventMessage, System.Diagnostics.TraceLevel traceLevel)
        {
            _eventSource = eventSource;
            _eventType = eventType;
            _eventMessage = eventMessage;
            _traceLevel = traceLevel;
        }
        /// <summary>
        /// Object from which the event originated
        /// </summary>
        public object EventSource
        {
            get
            {
                return _eventSource;
            }
        }
        /// <summary>
        /// Type of event
        /// </summary>
        public LogEventTypes EventType
        {
            get
            {
                return _eventType;
            }
        }
        /// <summary>
        /// Event description
        /// </summary>
        public string Message
        {
            get
            {
                return _eventMessage;
            }
        }
        /// <summary>
        /// Trace level
        /// </summary>
        public TraceLevel TraceLevel
        {
            get
            {
                return _traceLevel;
            }
        }
    }
}
